<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>module Racc - rdoc: Ruby Standard Library Documentation</title>


<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>

<script src="./js/jquery-3.2.0.min.js"></script>

<script src="./js/vue.min.js"></script>
<script src="./js/js.cookie.min.js"></script>

<link href="./css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="./css/rdoc.css" rel="stylesheet">
<link href="./css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
  var index_rel_prefix = "./";
  var darkModeCsseHref = "./css/rdoc-dm.css"
  var defaultModeCssHref = "./css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="module">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="./index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="./table_of_contents.html#pages">Pages</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    
<div class="nav-section">
  <h3>Table of Contents</h3>

  <ul class="link-list" role="directory">
    <li><a href="#module-Racc-label-Command-line+Reference">Command-line Reference</a>
    <li><a href="#module-Racc-label-Generating+Parser+Using+Racc">Generating Parser Using Racc</a>
    <li><a href="#module-Racc-label-Writing+A+Racc+Grammar+File">Writing A Racc Grammar File</a>
    <li><a href="#module-Racc-label-Parser">Parser</a>
    <li><a href="#module-Racc-label-Debugging">Debugging</a>
    <li><a href="#module-Racc-label-Racc+reported+syntax+error.">Racc reported syntax error.</a>
    <li><a href="#module-Racc-label-Racc+reported+-22XXXX+conflicts-22.">Racc reported “XXXX conflicts”.</a>
    <li><a href="#module-Racc-label-Generated+parsers+does+not+work+correctly">Generated parsers does not work correctly</a>
    <li><a href="#module-Racc-label-Re-distributing+Racc+runtime">Re-distributing Racc runtime</a>
    <li><a href="#module-Racc-label-Command-line+Reference">Command-line Reference</a>
    <li><a href="#module-Racc-label-Generating+Parser+Using+Racc">Generating Parser Using Racc</a>
    <li><a href="#module-Racc-label-Writing+A+Racc+Grammar+File">Writing A Racc Grammar File</a>
    <li><a href="#module-Racc-label-Parser">Parser</a>
    <li><a href="#module-Racc-label-Debugging">Debugging</a>
    <li><a href="#module-Racc-label-Racc+reported+syntax+error.">Racc reported syntax error.</a>
    <li><a href="#module-Racc-label-Racc+reported+-22XXXX+conflicts-22.">Racc reported “XXXX conflicts”.</a>
    <li><a href="#module-Racc-label-Generated+parsers+does+not+work+correctly">Generated parsers does not work correctly</a>
    <li><a href="#module-Racc-label-Re-distributing+Racc+runtime">Re-distributing Racc runtime</a>
  </ul>
</div>


    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
        
        
        
      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="module-Racc">
    <h1 id="module-Racc" class="module">
      module Racc
    </h1>

    <section class="description">
    
<p><a href="Racc.html"><code>Racc</code></a> is a LALR(1) parser generator. It is written in Ruby itself, and generates Ruby programs.</p>

<h2 id="module-Racc-label-Command-line+Reference">Command-line Reference<span><a href="#module-Racc-label-Command-line+Reference">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre>racc [-o&lt;var&gt;filename&lt;/var&gt;] [--output-file=&lt;var&gt;filename&lt;/var&gt;]
     [-e&lt;var&gt;rubypath&lt;/var&gt;] [--executable=&lt;var&gt;rubypath&lt;/var&gt;]
     [-v] [--verbose]
     [-O&lt;var&gt;filename&lt;/var&gt;] [--log-file=&lt;var&gt;filename&lt;/var&gt;]
     [-g] [--debug]
     [-E] [--embedded]
     [-l] [--no-line-convert]
     [-c] [--line-convert-all]
     [-a] [--no-omit-actions]
     [-C] [--check-only]
     [-S] [--output-status]
     [--version] [--copyright] [--help] &lt;var&gt;grammarfile&lt;/var&gt;</pre>
<dl class="rdoc-list label-list"><dt><code>grammarfile</code>
<dd>
<p><a href="Racc.html"><code>Racc</code></a> grammar file. Any extension is permitted.</p>
</dd><dt>-o+outfile+, –output-file=<code>outfile</code>
<dd>
<p>A filename for output. default is &lt;<code>filename</code>&gt;.tab.rb</p>
</dd><dt>-O+filename+, –log-file=<code>filename</code>
<dd>
<p>Place logging output in file <code>filename</code>. Default log file name is &lt;<code>filename</code>&gt;.output.</p>
</dd><dt>-e+rubypath+, –executable=<code>rubypath</code>
<dd>
<p>output executable file(mode 755). where <code>path</code> is the Ruby interpreter.</p>
</dd><dt>-v, –verbose
<dd>
<p>verbose mode. create <code>filename</code>.output file, like yacc’s y.output file.</p>
</dd><dt>-g, –debug
<dd>
<p>add debug code to parser class. To display debuggin information, use this ‘-g’ option and set @yydebug true in parser class.</p>
</dd><dt>-E, –embedded
<dd>
<p>Output parser which doesn’t need runtime files (racc/parser.rb).</p>
</dd><dt>-C, –check-only
<dd>
<p>Check syntax of racc grammar file and quit.</p>
</dd><dt>-S, –output-status
<dd>
<p>Print messages time to time while compiling.</p>
</dd><dt>-l, –no-line-convert
<dd>
<p>turns off line number converting.</p>
</dd><dt>-c, –line-convert-all
<dd>
<p>Convert line number of actions, inner, header and footer.</p>
</dd><dt>-a, –no-omit-actions
<dd>
<p>Call all actions, even if an action is empty.</p>
</dd><dt>–version
<dd>
<p>print <a href="Racc.html"><code>Racc</code></a> version and quit.</p>
</dd><dt>–copyright
<dd>
<p>Print copyright and quit.</p>
</dd><dt>–help
<dd>
<p>Print usage and quit.</p>
</dd></dl>

<h2 id="module-Racc-label-Generating+Parser+Using+Racc">Generating <a href="Racc/Parser.html"><code>Parser</code></a> Using <a href="Racc.html"><code>Racc</code></a><span><a href="#module-Racc-label-Generating+Parser+Using+Racc">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>To compile <a href="Racc.html"><code>Racc</code></a> grammar file, simply type:</p>

<pre>$ racc parse.y</pre>

<p>This creates Ruby script file “parse.tab.y”. The -o option can change the output filename.</p>

<h2 id="module-Racc-label-Writing+A+Racc+Grammar+File">Writing A <a href="Racc.html"><code>Racc</code></a> Grammar File<span><a href="#module-Racc-label-Writing+A+Racc+Grammar+File">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>If you want your own parser, you have to write a grammar file. A grammar file contains the name of your parser class, grammar for the parser, user code, and anything else. When writing a grammar file, yacc’s knowledge is helpful. If you have not used yacc before, <a href="Racc.html"><code>Racc</code></a> is not too difficult.</p>

<p>Here’s an example <a href="Racc.html"><code>Racc</code></a> grammar file.</p>

<pre>class Calcparser
rule
  target: exp { print val[0] }

  exp: exp &#39;+&#39; exp
     | exp &#39;*&#39; exp
     | &#39;(&#39; exp &#39;)&#39;
     | NUMBER
end</pre>

<p><a href="Racc.html"><code>Racc</code></a> grammar files resemble yacc files. But (of course), this is Ruby code. yacc’s $$ is the ‘result’, $0, $1… is an array called ‘val’, and $-1, $-2… is an array called ‘_values’.</p>

<p>See the Grammar File Reference for more information on grammar files.</p>

<h2 id="module-Racc-label-Parser"><a href="Racc/Parser.html"><code>Parser</code></a><span><a href="#module-Racc-label-Parser">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Then you must prepare the parse entry method. There are two types of parse methods in <a href="Racc.html"><code>Racc</code></a>, Racc::Parser#do_parse and Racc::Parser#yyparse</p>

<p>Racc::Parser#do_parse is simple.</p>

<p>It’s yyparse() of yacc, and <a href="Racc/Parser.html#method-i-next_token"><code>Racc::Parser#next_token</code></a> is yylex(). This method must returns an array like [TOKENSYMBOL, ITS_VALUE]. EOF is [false, false]. (TOKENSYMBOL is a Ruby symbol (taken from String#intern) by default. If you want to change this, see the grammar reference.</p>

<p>Racc::Parser#yyparse is little complicated, but useful. It does not use <a href="Racc/Parser.html#method-i-next_token"><code>Racc::Parser#next_token</code></a>, instead it gets tokens from any iterator.</p>

<p>For example, <code>yyparse(obj, :scan)</code> causes calling +obj#scan+, and you can return tokens by yielding them from +obj#scan+.</p>

<h2 id="module-Racc-label-Debugging">Debugging<span><a href="#module-Racc-label-Debugging">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>When debugging, “-v” or/and the “-g” option is helpful.</p>

<p>“-v” creates verbose log file (.output). “-g” creates a “Verbose Parser”. Verbose <a href="Racc/Parser.html"><code>Parser</code></a> prints the internal status when parsing. But it’s <em>not</em> automatic. You must use -g option and set +@yydebug+ to <code>true</code> in order to get output. -g option only creates the verbose parser.</p>

<h3 id="module-Racc-label-Racc+reported+syntax+error."><a href="Racc.html"><code>Racc</code></a> reported syntax error.<span><a href="#module-Racc-label-Racc+reported+syntax+error.">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Isn’t there too many “end”? grammar of racc file is changed in v0.10.</p>

<p><a href="Racc.html"><code>Racc</code></a> does not use ‘%’ mark, while yacc uses huge number of ‘%’ marks..</p>

<h3 id="module-Racc-label-Racc+reported+-22XXXX+conflicts-22."><a href="Racc.html"><code>Racc</code></a> reported “XXXX conflicts”.<span><a href="#module-Racc-label-Racc+reported+-22XXXX+conflicts-22.">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Try “racc -v xxxx.y”. It causes producing racc’s internal log file, xxxx.output.</p>

<h3 id="module-Racc-label-Generated+parsers+does+not+work+correctly">Generated parsers does not work correctly<span><a href="#module-Racc-label-Generated+parsers+does+not+work+correctly">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Try “racc -g xxxx.y”. This command let racc generate “debugging parser”. Then set @yydebug=true in your parser. It produces a working log of your parser.</p>

<h2 id="module-Racc-label-Re-distributing+Racc+runtime">Re-distributing <a href="Racc.html"><code>Racc</code></a> runtime<span><a href="#module-Racc-label-Re-distributing+Racc+runtime">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>A parser, which is created by <a href="Racc.html"><code>Racc</code></a>, requires the <a href="Racc.html"><code>Racc</code></a> runtime module; racc/parser.rb.</p>

<p>Ruby 1.8.x comes with <a href="Racc.html"><code>Racc</code></a> runtime module, you need NOT distribute <a href="Racc.html"><code>Racc</code></a> runtime files.</p>

<p>If you want to include the <a href="Racc.html"><code>Racc</code></a> runtime module with your parser. This can be done by using ‘-E’ option:</p>

<pre>$ racc -E -omyparser.rb myparser.y</pre>

<p>This command creates myparser.rb which ‘includes’ <a href="Racc.html"><code>Racc</code></a> runtime. Only you must do is to distribute your parser file (myparser.rb).</p>

<p>Note: parser.rb is ruby license, but your parser is not. Your own parser is completely yours.</p>

<p><a href="Racc.html"><code>Racc</code></a> is a LALR(1) parser generator. It is written in Ruby itself, and generates Ruby programs.</p>

<h2 id="module-Racc-label-Command-line+Reference">Command-line Reference<span><a href="#module-Racc-label-Command-line+Reference">&para;</a> <a href="#top">&uarr;</a></span></h2>

<pre>racc [-o&lt;var&gt;filename&lt;/var&gt;] [--output-file=&lt;var&gt;filename&lt;/var&gt;]
     [-e&lt;var&gt;rubypath&lt;/var&gt;] [--executable=&lt;var&gt;rubypath&lt;/var&gt;]
     [-v] [--verbose]
     [-O&lt;var&gt;filename&lt;/var&gt;] [--log-file=&lt;var&gt;filename&lt;/var&gt;]
     [-g] [--debug]
     [-E] [--embedded]
     [-l] [--no-line-convert]
     [-c] [--line-convert-all]
     [-a] [--no-omit-actions]
     [-C] [--check-only]
     [-S] [--output-status]
     [--version] [--copyright] [--help] &lt;var&gt;grammarfile&lt;/var&gt;</pre>
<dl class="rdoc-list label-list"><dt><code>grammarfile</code>
<dd>
<p><a href="Racc.html"><code>Racc</code></a> grammar file. Any extension is permitted.</p>
</dd><dt>-o+outfile+, –output-file=<code>outfile</code>
<dd>
<p>A filename for output. default is &lt;<code>filename</code>&gt;.tab.rb</p>
</dd><dt>-O+filename+, –log-file=<code>filename</code>
<dd>
<p>Place logging output in file <code>filename</code>. Default log file name is &lt;<code>filename</code>&gt;.output.</p>
</dd><dt>-e+rubypath+, –executable=<code>rubypath</code>
<dd>
<p>output executable file(mode 755). where <code>path</code> is the Ruby interpreter.</p>
</dd><dt>-v, –verbose
<dd>
<p>verbose mode. create <code>filename</code>.output file, like yacc’s y.output file.</p>
</dd><dt>-g, –debug
<dd>
<p>add debug code to parser class. To display debuggin information, use this ‘-g’ option and set @yydebug true in parser class.</p>
</dd><dt>-E, –embedded
<dd>
<p>Output parser which doesn’t need runtime files (racc/parser.rb).</p>
</dd><dt>-C, –check-only
<dd>
<p>Check syntax of racc grammar file and quit.</p>
</dd><dt>-S, –output-status
<dd>
<p>Print messages time to time while compiling.</p>
</dd><dt>-l, –no-line-convert
<dd>
<p>turns off line number converting.</p>
</dd><dt>-c, –line-convert-all
<dd>
<p>Convert line number of actions, inner, header and footer.</p>
</dd><dt>-a, –no-omit-actions
<dd>
<p>Call all actions, even if an action is empty.</p>
</dd><dt>–version
<dd>
<p>print <a href="Racc.html"><code>Racc</code></a> version and quit.</p>
</dd><dt>–copyright
<dd>
<p>Print copyright and quit.</p>
</dd><dt>–help
<dd>
<p>Print usage and quit.</p>
</dd></dl>

<h2 id="module-Racc-label-Generating+Parser+Using+Racc">Generating <a href="Racc/Parser.html"><code>Parser</code></a> Using <a href="Racc.html"><code>Racc</code></a><span><a href="#module-Racc-label-Generating+Parser+Using+Racc">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>To compile <a href="Racc.html"><code>Racc</code></a> grammar file, simply type:</p>

<pre>$ racc parse.y</pre>

<p>This creates Ruby script file “parse.tab.y”. The -o option can change the output filename.</p>

<h2 id="module-Racc-label-Writing+A+Racc+Grammar+File">Writing A <a href="Racc.html"><code>Racc</code></a> Grammar File<span><a href="#module-Racc-label-Writing+A+Racc+Grammar+File">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>If you want your own parser, you have to write a grammar file. A grammar file contains the name of your parser class, grammar for the parser, user code, and anything else. When writing a grammar file, yacc’s knowledge is helpful. If you have not used yacc before, <a href="Racc.html"><code>Racc</code></a> is not too difficult.</p>

<p>Here’s an example <a href="Racc.html"><code>Racc</code></a> grammar file.</p>

<pre>class Calcparser
rule
  target: exp { print val[0] }

  exp: exp &#39;+&#39; exp
     | exp &#39;*&#39; exp
     | &#39;(&#39; exp &#39;)&#39;
     | NUMBER
end</pre>

<p><a href="Racc.html"><code>Racc</code></a> grammar files resemble yacc files. But (of course), this is Ruby code. yacc’s $$ is the ‘result’, $0, $1… is an array called ‘val’, and $-1, $-2… is an array called ‘_values’.</p>

<p>See the Grammar File Reference for more information on grammar files.</p>

<h2 id="module-Racc-label-Parser"><a href="Racc/Parser.html"><code>Parser</code></a><span><a href="#module-Racc-label-Parser">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Then you must prepare the parse entry method. There are two types of parse methods in <a href="Racc.html"><code>Racc</code></a>, Racc::Parser#do_parse and Racc::Parser#yyparse</p>

<p>Racc::Parser#do_parse is simple.</p>

<p>It’s yyparse() of yacc, and <a href="Racc/Parser.html#method-i-next_token"><code>Racc::Parser#next_token</code></a> is yylex(). This method must returns an array like [TOKENSYMBOL, ITS_VALUE]. EOF is [false, false]. (TOKENSYMBOL is a Ruby symbol (taken from String#intern) by default. If you want to change this, see the grammar reference.</p>

<p>Racc::Parser#yyparse is little complicated, but useful. It does not use <a href="Racc/Parser.html#method-i-next_token"><code>Racc::Parser#next_token</code></a>, instead it gets tokens from any iterator.</p>

<p>For example, <code>yyparse(obj, :scan)</code> causes calling +obj#scan+, and you can return tokens by yielding them from +obj#scan+.</p>

<h2 id="module-Racc-label-Debugging">Debugging<span><a href="#module-Racc-label-Debugging">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>When debugging, “-v” or/and the “-g” option is helpful.</p>

<p>“-v” creates verbose log file (.output). “-g” creates a “Verbose Parser”. Verbose <a href="Racc/Parser.html"><code>Parser</code></a> prints the internal status when parsing. But it’s <em>not</em> automatic. You must use -g option and set +@yydebug+ to <code>true</code> in order to get output. -g option only creates the verbose parser.</p>

<h3 id="module-Racc-label-Racc+reported+syntax+error."><a href="Racc.html"><code>Racc</code></a> reported syntax error.<span><a href="#module-Racc-label-Racc+reported+syntax+error.">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Isn’t there too many “end”? grammar of racc file is changed in v0.10.</p>

<p><a href="Racc.html"><code>Racc</code></a> does not use ‘%’ mark, while yacc uses huge number of ‘%’ marks..</p>

<h3 id="module-Racc-label-Racc+reported+-22XXXX+conflicts-22."><a href="Racc.html"><code>Racc</code></a> reported “XXXX conflicts”.<span><a href="#module-Racc-label-Racc+reported+-22XXXX+conflicts-22.">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Try “racc -v xxxx.y”. It causes producing racc’s internal log file, xxxx.output.</p>

<h3 id="module-Racc-label-Generated+parsers+does+not+work+correctly">Generated parsers does not work correctly<span><a href="#module-Racc-label-Generated+parsers+does+not+work+correctly">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Try “racc -g xxxx.y”. This command let racc generate “debugging parser”. Then set @yydebug=true in your parser. It produces a working log of your parser.</p>

<h2 id="module-Racc-label-Re-distributing+Racc+runtime">Re-distributing <a href="Racc.html"><code>Racc</code></a> runtime<span><a href="#module-Racc-label-Re-distributing+Racc+runtime">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>A parser, which is created by <a href="Racc.html"><code>Racc</code></a>, requires the <a href="Racc.html"><code>Racc</code></a> runtime module; racc/parser.rb.</p>

<p>Ruby 1.8.x comes with <a href="Racc.html"><code>Racc</code></a> runtime module, you need NOT distribute <a href="Racc.html"><code>Racc</code></a> runtime files.</p>

<p>If you want to include the <a href="Racc.html"><code>Racc</code></a> runtime module with your parser. This can be done by using ‘-E’ option:</p>

<pre>$ racc -E -omyparser.rb myparser.y</pre>

<p>This command creates myparser.rb which ‘includes’ <a href="Racc.html"><code>Racc</code></a> runtime. Only you must do is to distribute your parser file (myparser.rb).</p>

<p>Note: parser.rb is ruby license, but your parser is not. Your own parser is completely yours.</p>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="Copyright">Copyright
          <dd>
          <dt id="VERSION">VERSION
          <dd>
          <dt id="Version">Version
          <dd>
        </dl>
        </section>



              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>. </p><p><a href="https://jamesbritt.bandcamp.com/">Hack your world.  Feed your head.  Live curious</a>.</p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

